<?
require_once('BooleanConverter.php');

class BooleanConverterTest extends PHPUnit_Framework_TestCase {
	protected $c;
	protected function setUp() {
		$this->c= new BooleanConverter;
	}
	function testGetAsString() {
		$this->assertNull($this->c->getAsString(null));

		$this->assertEquals('0',$this->c->getAsString(array()));
		$this->assertEquals('0',$this->c->getAsString(''));
		$this->assertEquals('0',$this->c->getAsString(false));

		$this->assertEquals('1',$this->c->getAsString(true));
		$this->assertEquals('1',$this->c->getAsString(1));
		$this->assertEquals('1',$this->c->getAsString(1231));
		$this->assertEquals('1',$this->c->getAsString('w'));
		$this->assertEquals('1',$this->c->getAsString('wqwe'));
		$this->assertEquals('1',$this->c->getAsString(array(1)));
	}
	function testGetAsDatatype() {
		$this->assertNull($this->c->getAsDatatype(null));

		$this->assertTrue($this->c->getAsDatatype('1'));
		$this->assertTrue($this->c->getAsDatatype(123));
		$this->assertTrue($this->c->getAsDatatype(array(12)));

		$this->assertFalse($this->c->getAsDatatype('0'));
		$this->assertFalse($this->c->getAsDatatype(0));
		$this->assertFalse($this->c->getAsDatatype(array()));
	}
}
